import { StorageEnum } from '@common/enums'
import type { AuthResponse } from './interface/auth'

export const checkToken = async (): Promise<AuthResponse> => {
  const token = localStorage.getItem(StorageEnum.AUTH_TOKEN)
  const user = localStorage.getItem(StorageEnum.USER_INFO)
  if (!token) {
    throw new Error('No token found')
  }
  return {
    token: token,
    user: user ? JSON.parse(user) : null,
  }
}
